home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_024 / csh / docs < prev    next >
Text File  |  1992-05-06  |  9KB  |  338 lines

  1.  
  2. DOCUMENTSATION TO Za SHELL
  3.  
  4. written by Matt Dillon, Public Domain
  5.  
  6. dillon@berkeley.edu,  ...!ucb-vax!dillon or ...!ucbvax!dillon
  7.  
  8.     SECTION        TITLE
  9.  
  10.        0        compiling
  11.        I        startup, auto sourcing your .login on startup
  12.        II        simple commands
  13.        III        Substitution/history Command line features
  14.        IV        The alias command
  15.        V        The set command
  16.        VI        special set variables
  17.        VII        labels and loops
  18.  
  19.     Appendix I    Complete Command list
  20.  
  21. 0.    compiling        ------------------------------------------
  22.  
  23.     Compile each module as follows: (specifying wherever your include 
  24.     directory is with the -i on lc1)
  25.  
  26.     lc1 -idf0:include/ xxx
  27.     lc2 -s -v xxx
  28.  
  29.     Then link with: (change libs to wherever yours are)
  30.  
  31.     alink df0:clib/lstartup.obj+main.o+globals.o+execom.o+comm1.o+comm2.o+set.o+sub.o library df0:clib/lc.lib+df0:clib/amiga.lib to shell
  32.  
  33.  
  34.  
  35.  
  36. I.    Startup          ------------------------------------------
  37.  
  38.     Assuming you've named your executable 'shell', you may execute the
  39.      shell FROM A CLI by typeing:
  40.  
  41.     shell
  42.  
  43.     To have the shell automagically source an initialization file,
  44.      specify the file as an argument:
  45.  
  46.     shell .login
  47.  
  48.     You can place this line in your startup-sequence file to have 
  49.      the workbench diskette go into a shell rather than the workbench.
  50.      It is suggested that you have a stack of 8192 (or more).  Thus, the
  51.      entire boot from a startup-sequence file would look like:
  52.  
  53.     stack 8192
  54.     shell .login
  55.  
  56.     Your initialization file is simply a sequence of shell commands. I
  57.      have included my .login file as an example (see LOGIN).  The file 
  58.      usually consists of aliases.
  59.  
  60.  
  61.  
  62. I.    Simple Commands     ------------------------------------------
  63.  
  64.     quit            -quit out of shell
  65.     set     varname string    -set variable to string
  66.     unset     varname        -unset a variable
  67.     alias     name string    -alias something to a sequence of commands
  68.     unalias name        -unalias that something
  69.     echo    string        -echo a string
  70.     source    file        -source a file (execute shell coms)
  71.     mv    from to        -exactly RENAME
  72.     cd    dir        -change dir (you can use .. to go back one)
  73.     rm    file file..    -remove files
  74.     mkdir    dir dir..    -create directories
  75.     history            -display history
  76.     mem            -display free memory 
  77.     cat    file        -'type' a file
  78.     dir    [file]        -directory of current dir or specified file/dir
  79.     devinfo    [dev:]        -device information current/specified
  80.     foreach var ( arglist) command
  81.                 -see description below
  82.     return            -abort a source file from the source file
  83.     if arg <=> arg        -conditional
  84.     else            -if-else
  85.     endif            -end of if or if-else
  86.     label name        -create a label (only within source files)
  87.     goto name        -goto a label   (only within source files)
  88.     inc var [count]        -increment an numeric-ascii variable
  89.     dec var [count]        -decrement 
  90.     input var        -input a line to the variable
  91.     version            -print shell version #
  92.  
  93.     Any other string is taken to be a disk command an Execute() 'd.  Note
  94. that the above commands can be abbreviated by any number of characters, so
  95. for instance you cannot have 'a' execute 'a'.. it will execute 'alias'. You
  96. would have to 'ram:a' (or whatever) to execute it.
  97.  
  98.  
  99.  
  100. III.    Substitution/history Command line features -----------------------
  101.  
  102.     * Standard commands may be abbreviated to any number of characters.
  103.     It is suggested that you do NOT abbreviate commands in source files
  104.     to keep those files compatible with future versions of my shell
  105.  
  106.     * Standard I/O redirection is to the current window. You may specify
  107.     redirection (<file >file) at any place on the command line.  I/O
  108.     redirection ONLY WORKS FOR DISK COMMANDS!  You cannot redirect 
  109.     internal commands.
  110.  
  111.     A command line looks like:
  112.  
  113.     COMMAND arg arg .... ; COMMAND arg arg ... .....
  114.  
  115.     Multiple commands are separated by a semicolon.  Alias substitution
  116.     is checked only on the COMAND (the name of the command) argument.
  117.     You may substitute set variables with:
  118.  
  119.     $variable_name
  120.  
  121.     You may do file expansion by specifying an argument which contains
  122.     '?' or '*' in it.  For instance:
  123.  
  124.     echo *.c *.h
  125.  
  126.     You may do history substitution with '!': (you can get your history
  127.     with the HISTORY command)
  128.  
  129.     !!                -re-execute last command
  130.     !partial            -re-execute last command beginning
  131.                      with 'partial'.
  132.     !123                -re-execute command # 123 
  133.  
  134.     For example:
  135.  
  136.     % echo charlie
  137.     charlie
  138.     % set a xxx
  139.     % !e
  140.     charlie
  141.  
  142.     You may overide any special character with the '\' character, So
  143.     if you do not want '*' to attempt a file-name expansion, use \*.
  144.  
  145.  
  146. IV.    The alias command    ------------------------------------------
  147.  
  148.     alias                -show current aliases
  149.     alias name            -show one alias
  150.     alias name comands        -create an alias
  151.  
  152.     % alias logout quit
  153.     % alias hello  "echo hello; echo hello"
  154.  
  155.     The quotes are required or the semi-colon might be construed as a
  156.     command delimeter rather than part of the alias.  There is one other
  157.     feature of the alias. You can collect argument given after an
  158.     alias with:
  159.  
  160.     alias name "%var commands. .. $var ... ."
  161.  
  162.     E.g. place a '%var' as the first argument in the substitution string,
  163.     and the remaining argument will be placed in that variable for the
  164.     duration of the alias.  For example:
  165.  
  166.     % alias xxx "%i echo $i $i $i $i"
  167.     % xxx hello
  168.  
  169.     hello hello hello hello
  170.  
  171.  
  172.  
  173. V.    The set command        ------------------------------------------
  174.  
  175.     set                -show set variables
  176.     set var                -show a single set variable or
  177.                      set to "" if it doesn't existd
  178.     set var name            -set a variable to a string
  179.  
  180.     .. $var..            -use a set variable
  181.  
  182.  
  183.  
  184. VI.    Special set variables    ------------------------------------------
  185.  
  186.     Additionaly, the following set variables are special:
  187.  
  188.     _prompt      command
  189.     _history  value
  190.  
  191.  
  192.     The _prompt variable contains the command to execute to display your
  193.     prompt.  Usually, this is 
  194.     
  195.     echo -n "%"
  196.  
  197.     The _history variable sets the number of previous commands which
  198.     you want the shell to remember.... usually around 20
  199.  
  200.  
  201. VII.    Labels and loops    ------------------------------------------
  202.  
  203.     label name
  204.     goto label
  205.     if arg <=> arg
  206.     else
  207.     endif
  208.  
  209.     label and goto can only be executed from a shell script.  These
  210.     allow you to randomly go anywhere within a shell script.  Coupled
  211.     with the conditionals, you can create loops if you wish.  As far
  212.     as the conditionals go, if the left argument is numeric, both
  213.     arguments are treated as numeric rather than string for the
  214.     comparision.
  215.  
  216.     if 1 < 5    smaller
  217.     if 1 > 4    larger
  218.     if a <= back    smaller or equal
  219.          >=        larger or equal
  220.          =        equal
  221.          !=        not equal
  222.     
  223.     IF's, ELSEs, and ENDIF's may be executed at any time.  Additionaly,
  224.     a GOTO or RETURN from within a source file 'does the right thing'
  225.     in terms of restoring the correct conditional state.
  226.  
  227.  
  228. AP I    Complete Command list    ------------------------------------------
  229.  
  230. QUIT            
  231.     Quit out of the shell... 
  232.  
  233. SET
  234. SET name
  235. SET name string
  236.     Display set variables, display a single variable or set to "" if
  237.     it doesn't exist, and set a variable to a string.
  238.  
  239. UNSET name name...
  240.     unset one or more variables
  241.  
  242. ALIAS
  243. ALIAS name
  244. ALIAS name command
  245. ALIAS name "command;command..."
  246.     same as set (but in a different name space) in terms of operation.
  247.     alias a name to a command (sequence).  When using the alias, you cannot
  248.     abbreviate the name.
  249.  
  250. UNALIAS name name name...
  251.     unalias one or more variables
  252.  
  253. ECHO [-n] string
  254.     echo a string (-n means without newline at end)
  255.  
  256. SOURCE file
  257.     execute shell commands from a file.
  258.  
  259. RETURN
  260.     return from within a source file
  261.  
  262. MV from to
  263.     RENAME, exactly
  264.  
  265. CD [dir]
  266.     cd to a directory, cd to your current device base if you do not 
  267.     specify any arguments.  You may specify '..' in your path to go
  268.     back a directory.
  269.  
  270. RM file file file...
  271.     remove file(s)
  272.  
  273. MKDIR name name name
  274.     create directory(s)
  275.  
  276. HISTORY
  277.     Display history of commands that have been executed
  278.  
  279. MEM
  280.     Display memory free
  281.  
  282. CAT file file ..
  283.     TYPE files out
  284.  
  285. DIR [file file..]
  286.     Directory (use current dir if no args given)
  287.  
  288. DEVINFO [dev: dev: ...]
  289.     Device information (use current device if no args given)
  290.  
  291. FOREACH var ( arglist ) command
  292. FOREACH var ( arglist ) "command;command..."
  293.     Foreach space delimited item in arglist, place that item in the
  294. specified set variable, and execute the specified command.  This allows you
  295. to do a given operation on several 'arguments' automatically.  you MUST BE
  296. SURE to delimit the parenthesis by a space on either side!!!
  297.  
  298.     % foreach i ( *.c ) echo $i
  299.     comm1.c 
  300.     comm2.c
  301.     execom.c
  302.     globals.c
  303.     main.c
  304.     set.c
  305.     sub.c
  306.  
  307. IF arg <=> arg
  308. ELSE
  309. ENDIF
  310.     Conditional.  (<,>,<=,>=,=,!=)  If the left argument is a number,
  311. both arguments are taken to be numbers and compared as numbers instead of
  312. strings.  ALWAYS REMEMBER to put an 'endif' to end the conditional.
  313.  
  314. LABEL name
  315. GOTO name
  316.     Labels and goto's.  These only work inside source files, since I
  317. use fseek() and you can't fseek() your tty.
  318.  
  319. INC var [count]
  320. DEC var [count]
  321.     Increment and decrement a variable numerically by one (or count if
  322. specified)
  323.  
  324.  
  325. INPUT var
  326.     This is a cluge. You can input a string into a variable.  E.G.
  327.  
  328.     echo -n Input a filename:
  329.     input charlie
  330.     source $charlie
  331.  
  332. VERSION
  333.     print the current version
  334.  
  335.  
  336.  
  337.  
  338.